package space.jevin.jevinboot.exception.system;

import space.jevin.jevinboot.exception.EnumErrorMessage;

/**
 * 系统错误异常码
 *
 * @author zhangjiehang
 * @version V1.0
 * @date 2021/5/11 1:47 下午
 */
public enum ErrorCode implements EnumErrorMessage {

    /**
     * 成功异常
     */
    SUCCESS("S0000", "success"),
    /**
     * 参数校验错误
     */
    PARAM("S0002", "参数校验错误");

    private final String code;

    private final String error;

    ErrorCode(String code, String error) {
        this.code = code;
        this.error = error;
    }

    public static ErrorCode getValueByKey(String key) {
        for (ErrorCode s : ErrorCode.values()) {
            if (s.getCode().equals(key)) {
                return s;
            }
        }
        return null;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return error;
    }
}
